package com.ruoyi.security.convert;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.security.domain.SecurityTradingCalendar;
import com.ruoyi.security.vo.SecurityTradingCalendarResponse;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * 证券交易日历转换器
 * 
 * @author yeoman
 * @date 2025-01-15
 */
@Mapper(imports = {DateUtils.class})
public interface SecurityTradingCalendarConvert {
    
    SecurityTradingCalendarConvert INSTANCE = Mappers.getMapper(SecurityTradingCalendarConvert.class);
    
    /**
     * 转换响应数据为交易日历实体
     * 
     * @param data 响应数据
     * @return 交易日历实体
     */
    @Mapping(target = "date", expression = "java(DateUtils.parseDate(data.getJyrq()))")
    @Mapping(target = "weekday", source = "zrxh")
    @Mapping(target = "tradingDayFlag", expression = "java(Integer.valueOf(data.getJybz()))")
    SecurityTradingCalendar toSecurityTradingCalendar(SecurityTradingCalendarResponse.Data data);
    
}
